package com.yequan.springmvc.handleradapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yequan.springmvc.handler.iface.HttpServletRequestHandler;
import com.yequan.springmvc.handleradapter.iface.HandlerAdapter;

/**
 * 将HttpServletRequestHandler适配成HandlerAdapter
 * 
 * @author 灭霸詹
 *
 */
public class HttpServletRequestHandlerAdapter implements HandlerAdapter {

	@Override
	public boolean supports(Object handler) {
		return (handler instanceof HttpServletRequestHandler);
	}

	@Override
	public void handleRequest(Object handler, HttpServletRequest request, HttpServletResponse response) {
		try {
			((HttpServletRequestHandler) handler).handleRequest(request, response);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
